package com.bst.etl.vo;

import com.alibaba.druid.util.JdbcConstants;
import com.bst.base.domain.BaseDb;
import com.bst.common.utils.StringUtils;

public class OdsTableCreSqlVO {

    private String qrySql;

    private String tableName;

    private Integer idDb;

    private BaseDb db;

    public String getQrySql() {
        if(StringUtils.isEmpty(qrySql)) {
            String sdDbtp = db.getSdDbtp();
            if (JdbcConstants.MYSQL.equals(sdDbtp)) {
                return "select * from "+tableName+" limit 1 ";
            } else if (JdbcConstants.ORACLE.equals(sdDbtp)) {
                return "select * from "+tableName +" where rownum<2";
            }  else if (JdbcConstants.SQL_SERVER.equals(sdDbtp)) {
                return "select top 1 * from "+tableName;
            }
        } else {
            return  "select * from ("+qrySql+") tt where 1=2";
        }
        return qrySql;
    }

    public void setQrySql(String qrySql) {
        this.qrySql = qrySql;
    }

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public Integer getIdDb() {
        return idDb;
    }

    public void setIdDb(Integer idDb) {
        this.idDb = idDb;
    }

    public BaseDb getDb() {
        return db;
    }

    public void setDb(BaseDb db) {
        this.db = db;
    }
}
